import { getUser } from '@/api/account';
import { myTask } from '@/api/task';

const actions = {
	// 获取用户信息
	
	getUser({ commit }) {
		getUser().then(res => {
			if (res.message === 'success') {
				console.log('用户信息=',res);
				const { data: _data } = res;
				commit('setUserData', {
					userCode: _data.userCode,
					nickName: _data.nickName,
					picturePath: _data.picturePath,
					userId: _data.id,
					USER_TYPE: (_data['userExtension'] || {}).wheatherTeam,
					//注册全局，基本信息是否填写，“身份、技能、财务”是否通过
					isPassIdentity: _data.userExtension.certificatePassed,
					isPassFinance: _data.userExtension.settleCertificatePassed,
					isPassSkill: _data.userExtendList.length > 0




				})
			}
		})
	},
	// 我的任务 --》 搜索
	myTask ({commit}, keyword) {
		uni.showLoading({
			title: '搜索中...',
			mask: true
		});
		myTask({
			jsonStr: JSON.stringify({
				"page":{
					"page": 1,
					"limit": 10,
					"sort":"",
					"desc":""
				},
				"conditionVo":{"conditionType":"and","queryVos":[{"condition":"01","field":"taskId","value": keyword}]}
			})
		}).then(res => {
			if(res.success){
				const { data: {list, totalRow} } = res;
				commit('searchMyTask', list);
				commit('searchMyTaskRow', totalRow);
			}else{
				uni.showToast({
					title: res.msg,
					icon: 'none'
				})
			}
		}).finally(() => {
			uni.hideLoading()
		})
	}
}

export default actions